package com.qdu.mapper;

import com.qdu.bean.bikeWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class rentPerWorkHourMapper extends Mapper<LongWritable,Text, Text, bikeWritable> {
    bikeWritable bw3=new bikeWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] data=line.split(",");
        String[] time=data[0].split(" ");
        String[] time_xf=time[1].split(":");
        String time_real="";
        if (data[3].equals("1")) {
            int casual = Integer.parseInt(data[9]);
            int registered = Integer.parseInt(data[10]);
            int count = Integer.parseInt(data[11]);
            bw3.set2(casual, registered, count);
        }
        if (Integer.parseInt(time_xf[0])<10){
             time_real="0"+time[1];
        }else {
            time_real=time[1];
        }
        context.write(new Text(time_real),bw3);
    }
}
